﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace LambdaToSql.Interface
{
    /// <summary>
    /// 更新接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IUpdateable<T> where T : class, new()
    {
        /// <summary>
        /// 数据库上下文对象
        /// </summary>
        LambdaToSql.EntityModel.DbContext Context { get; set; }

        /// <summary>
        /// 更新实体对象
        /// </summary>
        IUpdateable<T> Update(T obj);

        /// <summary>
        /// 更新条件
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        IUpdateable<T> Where(Expression<Func<T, bool>> exp);

        /// <summary>
        /// 编辑列
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        IUpdateable<T> UpdateColumns(Expression<Func<T, object>> exp);

        /// <summary>
        /// 忽略编辑列
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> exp);

        ///// <summary>
        ///// 更新字段值  ex=>new {ex.name="1",ex.age=2}
        ///// </summary>
        ///// <param name="exp"></param>
        ///// <returns></returns>
        //IUpdateable<T> SetColumns(Expression<Func<T, object>> exp);

        /// <summary>
        /// 执行更新 返回影响的行数
        /// </summary>
        /// <returns></returns>
        int ExecuteNonQuery();

        /// <summary>
        /// 执行更新 返回带debug信息
        /// </summary>
        /// <returns></returns>
        LambdaToSql.EntityModel.Result<int> ExecuteNonQuery(bool debug);
    }
}
